package com.zy.web.controller.model;

import lombok.Builder;
import lombok.Data;

/**
 * @program: monitor147
 * @description:
 * @author: zy
 * @create: 2025-06-11 19:17
 */
@Data
@Builder   //构造器注解   =>   链式调用.
public class ResponseResult {
    private int code;
    private String msg;
    private Object data;

    public static ResponseResult ok(){
        return ResponseResult.builder().code(1).msg("操作成功").build();
    }
    public static ResponseResult ok(String message){
        return ResponseResult.builder().code(1).msg(message).build();
    }

    public static ResponseResult error(){
        return ResponseResult.builder().code(0).msg("操作失败").build();
    }
    public static ResponseResult error(String message){
        return ResponseResult.builder().code(0).msg(message).build();
    }

    //放入Data的问题
    public <T> ResponseResult setData(  T t ){
        this.data=t;
        return this;
    }
    //    ResponseResult rr= ResponseResult.ok().setData( 123 );
    //

}
